package com.esri.core.internal.tasks;

import java.io.InterruptedIOException;
import java.io.Serializable;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;

/* loaded from: classes.dex */
public abstract class a<V> implements Serializable, Callable<V> {
    private static final long serialVersionUID = 1;
    protected f actionInput;
    TaskListener<V> listener;
    short state = 1;

    public abstract V execute() throws Exception;

    /* JADX INFO: Access modifiers changed from: protected */
    public a(f fVar, TaskListener<V> taskListener) {
        this.listener = taskListener == null ? new TaskListener<V>() { // from class: com.esri.core.internal.tasks.a.1
            @Override // com.esri.core.internal.tasks.TaskListener
            public void onCompletion(short s, V v) {
            }

            @Override // com.esri.core.internal.tasks.TaskListener
            public void onError(Throwable th) {
                th.printStackTrace();
            }
        } : taskListener;
        this.actionInput = fVar;
    }

    public TaskListener<V> getListener() {
        return this.listener;
    }

    public void setListener(TaskListener<V> taskListener) {
        this.listener = taskListener;
    }

    public f getActionInput() {
        return this.actionInput;
    }

    public void setActionInput(f fVar) {
        this.actionInput = fVar;
    }

    @Override // java.util.concurrent.Callable
    public final V call() {
        V v = null;
        try {
            try {
                try {
                    v = execute();
                } catch (InterruptedException unused) {
                    this.state = (short) 0;
                } catch (Throwable th) {
                    if (Thread.currentThread().isInterrupted()) {
                        this.state = (short) 0;
                    } else {
                        this.state = (short) -1;
                        this.listener.onError(th);
                    }
                }
            } catch (InterruptedIOException unused2) {
                this.state = (short) 0;
            } catch (ExecutionException unused3) {
                this.state = (short) 0;
            }
            this.listener.onCompletion(this.state, v);
            return v;
        } catch (Throwable th2) {
            this.listener.onCompletion(this.state, v);
            throw th2;
        }
    }
}
